package com.huey.utils.thread.countDownLatch;

import java.util.concurrent.CountDownLatch;

/**
 * @author xubo
 * @date 2022/10/6 16:45
 */
public class Test01 {
    public static void main(String[] args) throws InterruptedException{
        CountDownLatch countDownLatch = new CountDownLatch(3);
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("aWork:  A ");
                countDownLatch.countDown();
                try {
                    countDownLatch.await();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                System.out.println("aWork:  B");
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("bWork:  A ");
                countDownLatch.countDown();
                try {
                    countDownLatch.await();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                System.out.println("bWork:  B");
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("cWork:  A ");
                countDownLatch.countDown();
                try {
                    countDownLatch.await();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();

                }
                System.out.println("cWork:  B");
            }

        }).start();
    }

}
